package com.chenfan.mcn.extension.excel;

import org.apache.commons.collections4.MapUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author wulg
 * @date 2023/10/30
 */
public class ExcelHyperlinkDataHolder {

    public static final ThreadLocal<Map<String, String>> holder = ThreadLocal.withInitial(HashMap::new);

    public static void add(String fileId, String fileName) {
        Map<String, String> map = holder.get();
        map.putIfAbsent(fileId, fileName);
    }

    public static String get(String fileId) {
        Map<String, String> map = holder.get();
        return map.get(fileId);
    }

    public static void clear() {
        Map<String, String> map = holder.get();
        if(MapUtils.isNotEmpty(map)) {
            map.clear();
        }
        holder.remove();
    }
}
